program main
    implicit none
    integer :: t,n,stat
    logical :: flag=.false.
    open(233,file='7-2-input.dat',form='UNFORMATTED',access='SEQUENTIAL')
    open(234,file='7-2-output.dat',form='UNFORMATTED',access='SEQUENTIAL')
    read(*,*)n
    stat = 0
    do while(stat==0)
        read(233,iostat=stat)t
        if(t>=n .and. (.not.flag))then
            write(234)n
            flag=.true.
        end if
        write(234)t
    end do
    close(233)
    close(234)
end program
